// 变量类型推断
let age1 = 18

// 变量类型注解 （推荐）
let age2: number = 18

let numArr = [1, 2, 3]
// 类型断言（谨慎使用），保证result为一个number
const result = numArr.find(item => item > 2) as number
const r = result * 5

console.log(age1.toPrecision(2));

// 基本变量类型：number, string, boolean, null, undefined
let v1: number = 1
let v2: string = '1'
let v3: boolean = true
let v4: null = null
let v5: undefined = undefined

// 联合类型，变量为string, null或undefined
let v6: string | null | undefined = null

// 限制变量可被设置的值
let v7: 1 | 2 | 3 = 2
